package xyz.tanxiao.links.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import xyz.tanxiao.links.config.GlobalProperties;
import xyz.tanxiao.links.entity.SlIpBlacklist;
import xyz.tanxiao.links.mapper.SlIpBlacklistMapper;
import xyz.tanxiao.links.service.SlIpBlacklistService;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@Service
public class SlIpBlacklistServiceImpl extends ServiceImpl<SlIpBlacklistMapper, SlIpBlacklist> implements SlIpBlacklistService {

	private final GlobalProperties globalProperties;


	/**
	 * 查询触发次数大于指定次数的黑名单信息
	 *
	 * @param triggerCount 触发限流次数
	 * @return 黑名单信息
	 */
	@Override
	public List<SlIpBlacklist> getBlacklist(int triggerCount) {
		return this.list(
			Wrappers.lambdaQuery(SlIpBlacklist.class).gt(SlIpBlacklist::getTriggerCount, triggerCount)
		);
	}

}